{extend name="../../admin/view/main"}

{block name="button"}
{if auth("add")}
<button class='layui-btn layui-btn-sm layui-btn-primary' data-open='{:url("add")}'>添加产品</button>
{/if}

{if isset($type) and $type eq 'index'}
{if auth("remove")}
<button class='layui-btn layui-btn-sm layui-btn-primary' data-action='{:url("remove")}' data-rule="id#{key};deleted#1">删除产品</button>
{/if}
{else}
{if auth("remove")}
<button class='layui-btn layui-btn-sm layui-btn-primary' data-action='{:url("remove")}' data-confirm="确定要恢复这些数据吗？" data-rule="id#{key};deleted#0">恢复产品</button>
{/if}
{/if}

{/block}

{block name="content"}
<div class="layui-tab layui-tab-card think-bg-white">
    <ul class="layui-tab-title">
        {foreach ['index'=>'产品管理','recycle'=>'回 收 站'] as $k=>$v}
        {if isset($type) and $type eq $k}
        <li class="layui-this" data-open="{:url('index')}?type={$k}">{$v}</li>
        {else}
        <li data-open="{:url('index')}?type={$k}">{$v}</li>
        {/if}{/foreach}
    </ul>
    <div class="layui-tab-content">
        {include file='shop/goods/index_search'}
        <table class="layui-table margin-top-10" lay-skin="line">

            <thead>
            <tr>
                <th class='list-table-check-td think-checkbox'>
                    <label><input data-auto-none data-check-target='.list-check-box' type='checkbox'></label>
                </th>
                <th class='list-table-sort-td'>
                    <button class="layui-btn layui-btn-xs" data-reload type="button">刷 新</button>
                </th>
                <th class='text-left nowrap'>产品信息</th>
                <th class='text-left nowrap'>产品分类</th>
                <th class='text-left nowrap'>公司</th>
                <th class='text-left nowrap'>投资时长</th>
                <th class='text-left nowrap'>年利率</th>
                <th class='text-left nowrap'>备注</th>
                <th class='text-left nowrap'>产品状态</th>
                <th></th>
            </tr>
            </thead>

            <tbody>
            {notempty name='list'}
            {foreach $list as $key=>$vo}
            <tr>
                <td class='list-table-check-td think-checkbox'>
                    <label><input class="list-check-box" type='checkbox' value='{$vo.id}'></label>
                </td>
                <td class='list-table-sort-td'>
                    <label><input class="list-sort-input" data-action-blur="{:request()->url()}" data-loading="false" data-value="id#{$vo.id};action#sort;sort#{value}" value="{$vo.sort}"></label>
                </td>
                <td class='nowrap'>
                    <div class="inline-block text-top sub-span-blue">
                        <div>产品名称：<span>{$vo.name|default='--'}</span></div>
                    </div>
                </td>
                <td>
                    <div class="nowrap">
                        {$vo.cateinfo.name}
                    </div>
                </td>
                <td>
                    <div class="nowrap">
                        {$vo.companyinfo.name|default=''}
                    </div>
                </td>
                <td>
                    <div class="nowrap">
                        {$vo.time_number}--
                        {switch $vo.time_type}
                        {case 1 }月{/case}
                        {case 2 }季{/case}
                        {case 3 }年{/case}
                        {case 4 }天{/case}
                        {/switch}
                    </div>
                </td>
                <td>
                    <div class="nowrap">
                        {$vo.annual_rate}
                    </div>
                </td>
                <td>
                    <div class="nowrap">
                        {$vo.remark}
                    </div>
                </td>
                <td class='nowrap sub-strong-blue'>

                    {if auth("edit")}
                    <a class="layui-btn layui-btn-xs" data-open='{:url("edit")}?id={$vo.id}'>编 辑</a>
                    {else}
                    <a class="layui-btn layui-btn-xs layui-btn-primary layui-disabled" data-tips-text="您没有编辑产品的权限哦！">编 辑</a>
                    {/if}

                    {if isset($type) and $type eq 'index'}
                    {if isset($vo.status) and $vo.status eq 1}
                    {if auth("state")}
                    <a class="layui-btn layui-btn-xs layui-btn-warm" data-action="{:url('state')}" data-value="id#{$vo.id};status#0">下 架</a>
                    {else}
                    <a class="layui-btn layui-btn-xs layui-btn-primary layui-disabled" data-tips-text="您没有下架产品的权限哦！">下 架</a>
                    {/if}
                    {else}
                    {if auth("state")}
                    <a class="layui-btn layui-btn-xs layui-btn-warm" data-action="{:url('state')}" data-value="id#{$vo.id};status#1">上 架</a>
                    {else}
                    <a class="layui-btn layui-btn-xs layui-btn-primary layui-disabled" data-tips-text="您没有上架产品的权限哦！">上 架</a>
                    {/if}
                    {/if}
                    {if auth("remove")}
                    <a class="layui-btn layui-btn-xs layui-btn-danger" data-action="{:url('remove')}" data-confirm="确定要移入回收站吗？" data-value="id#{$vo.id};deleted#1">删 除</a>
                    {/if}
                    {else}
                    {if auth("remove")}
                    <a class="layui-btn layui-btn-xs layui-btn-normal" data-action="{:url('remove')}" data-value="id#{$vo.id};deleted#0">恢 复</a>
                    {/if}
                    {/if}
                </td>
            </tr>
            {/foreach}
            {/notempty}
            </tbody>
        </table>
        {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
    </div>
    <script>form.render()</script>
</div>
{/block}